class Entry < ActiveRecord::Base
  belongs_to :list
  
  validates_uniqueness_of :url, :scope => :list_id
  validates_presence_of :url, :list_id
  # Status can equal 1 or 2 indicating unread and read respectively
  validates_inclusion_of :status, :in => 1..2
  
  def display_title
    if (title.nil?)
      url
    else
      if (title.empty?)
        url
      else
        title
      end
    end
  end
  
  def favicon
    begin
      'http://www.google.com/s2/favicons?domain=' + URI.parse(url).host
    rescue
      ''
    end
  end
end
